import cryptoJS from 'crypto-js'

const SECRET_IV = "9632741_haimi_85";
const SECRET_KEY = "85_haimi_9632741";

/**
 * 加密方法
 * @param content 
 */
function encrypt(content) {
    //设置秘钥和秘钥偏移量
    const key = cryptoJS.enc.Utf8.parse(SECRET_KEY);
    const iv = cryptoJS.enc.Utf8.parse(SECRET_IV);
    const srcs = cryptoJS.enc.Utf8.parse(content);
    const encrypted = cryptoJS.AES.encrypt(srcs, key, {
        iv: iv ,
        mode: cryptoJS.mode.CBC,
        padding: cryptoJS.pad.ZeroPadding
    })
    return cryptoJS.enc.Base64.stringify(encrypted.ciphertext);
}

export default encrypt